home *** CD-ROM | disk | FTP | other *** search
- #include <astsbpar.h> //Link necessary header
- #include <stdio.h>
-
- int main ()
- {
- char functionStr[255];
- char xvalStr[255];
- char yvalStr[255];
- double xyval[2];
-
- //Loading of the csbparse.DLL
- if (InitSTDsbParserDLL() == true) {
- printf("\n\nEnter a function to solve: f(x,y)=");
- scanf("%255s", functionStr);
-
- //Create an sbParser object and receive its HANDLE
- HANDLE hParser;
- hParser = CreateNewParser(functionStr, 2, "xy");
-
- double Result;
- char strResult[30];
- if (GetIsError(hParser))
- {
- //An error has occurred
- printf("\n\nAn error has occured... GlobalError==");
- dtochar(strResult, GetGlobalError(hParser));
- printf(strResult);
-
- Result = 0;
- }
- else
- {
- bool err = false;
- int pos;
-
- printf("\n\nEnter the x value: x=");
- scanf("%255s", xvalStr);
- printf("\nEnter the y value: y=");
- scanf("%255s", yvalStr);
-
- //Convert the strings of the variables to long double
- xyval[0]=chartod(xvalStr,&pos);
- if (pos >= 0)
- {
- printf("\nThe string of the variable x cannot be converted to long double.");
-
- err=true;
- }
- xyval[1]=chartod(yvalStr,&pos);
- if (pos >= 0)
- {
- printf("\nThe string of the variable y cannot be converted to long double.");
-
- err=true;
- }
-
- if (err == false) {
- Result = dGetResultExt(hParser, xyval);
-
- if (GetIsError(hParser))
- {
- //An error has occurred
- printf("\n\nAn error has occured... GlobalError==");
- dtochar(strResult, GetGlobalError(hParser));
- printf(strResult);
-
- Result = 0;
- }
- else
- {
- dtochar(strResult, Result, 10, true);
- printf("\n\nResult is ");
- printf(strResult);
- }
- }
- }
-
- //Delete of the sbParser object
- DeleteParser(hParser);
-
- //Unloading of the csbparse.DLL
- DeinitSTDsbParserDLL();
- printf("\n\nClick RETURN");
-
- int c;
- while ((c = getchar()) != '\n') {}
- while ((c = getchar()) != '\n') {}
- }
- else {
- printf("\n\nInitSTDsbParserDLL() failed");
-
- int c;
- printf("\n\nClick RETURN");
- while ((c = getchar()) != '\n') {}
- }
- return 0;
- }
-